﻿@model Vizzio.Models.GastosDeImportacion

@{
    ViewBag.Title = "Editar Gasto de Importacion";
}

<h2>Editar Gasto de Importacion</h2>


@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <h4>GastosDeImportacion</h4>
        <hr />
        @Html.ValidationSummary(true)
        @Html.HiddenFor(model => model.IngresoDeProductoID)

        <div class="form-group">
           @* @Html.LabelFor(model => model.ImportacionID, "ImportacionID", new { @class = "control-label col-md-2" })*@
            <div class="col-md-10">            
               @* @Html.HiddenFor(model => model.IngresoDeProductoID, new { Model.IngresoDeProductoID })*@
                @Html.HiddenFor(model => model.GastosDeImportacionID, new { Model.GastosDeImportacionID})
            </div>
        </div>

        <div class="control-group form-group">
            @Html.LabelFor(model => model.Detalle, new { @class = "control-label col-md-2" })
            <div class="col-md-10 controls">
                @Html.TextBoxFor(model => model.Detalle, new { @class = "form-control", required = "", maxlength = "500", data_validation_maxlength_message = "Muy largo: Ingrese 500 o menos caracteres", data_validation_required_message = "Campo requerido", minlength = "6", data_validation_minlength_message = "Muy corto: Ingrese al menos 6 caracteres", data_validation_callback_callback = "validar_detalle_gasto_importacion" })
                <p class="help-block">6 a 500 Caracteres Maximo</p>
            </div>
        </div>


        <div class="control-group form-group">
            @Html.LabelFor(model => model.Costo, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.TextBoxFor(model => model.Costo, new { @class = "form-control", required = "", maxlength = "10", data_validation_maxlength_message = "Muy largo: Ingrese 10 o menos digitos", data_validation_required_message = "Campo requerido", max = "9999999", data_validation_max_message = "Demaciado grande: Debe ser menor a 9999999.99", min = "1", data_validation_min_message = "Debe ser mayor a 0", data_validation_regex_regex = "([0-9]+)([,]{0,1}[0-9]{1,2}){0,1}", data_validation_regex_message = "Solo numeros con 2 decimales a lo mucho. Separador decimal: [ , ]" })
                @*@Html.ValidationMessageFor(model => model.Costo)*@
                <p class="help-block">de 1 a 9999999 Maximo</p>
            </div>
        </div>
        @*<div class="control-group control-group form-group">
            @Html.LabelFor(model => model.Moneda, new { @class = "control-label col-md-2" })
            <div class="col-md-10 controls">
                @Html.DropDownListFor(model => model.Moneda, new[] { new SelectListItem { Value = "Dolar", Text = "Dolar", Selected = true }, new SelectListItem { Value = "Boliviano", Text = "Boliviano" }, new SelectListItem { Value = "PesoChileno", Text = "Peso Chileno" } })
            </div>
        </div>*@

        <div class="control-group form-group">
            @Html.LabelFor(model => model.Lugar, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.TextBoxFor(model => model.Lugar, new { @class = "form-control", required = "", data_validation_required_message = "Campo requerido", maxlength = "30", data_validation_maxlength_message = "Muy largo: Ingrese 30 o menos caracteres", minlength = "1", data_validation_minlength_message = "Muy corto: Ingrese al menos 1 caracter", data_validation_regex_regex = "[A-ZñÑa-z0-9_\\-\\.,#\\/ ]+", data_validation_regex_message = "Solo caracteres Alfanumericos incluido [-_.,_/#]" })
                @*@Html.ValidationMessageFor(model => model.Lugar)*@
                <p class="help-block">1 a 30 caracteres</p>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Modificar" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Lista de Gastos", "Index", new { id = Model.IngresoDeProductoID })
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")

<script>
    var aux = @Model.GastosDeImportacionID;
    function validar_detalle_gasto_importacion($el, value, validar_ci) {

        var obj = { Detalle: value, GastoID:aux };//Datos enviados
        $.ajax({
            type: "POST",
            url: "http://localhost:6490/Service/WebServiceGetProductos.asmx/ModificarDetalleGastoDeImportacionDisponible",
            dataType: "json",
            data: JSON.stringify(obj),
            contentType: "application/json; charset=utf-8",
            success: function (data) {
                validar_ci({
                    value: value,
                    valid: JSON.parse(data.d),
                    message: "Duplicidad: El gasto de Importacion ya fue registrado!!"
                });
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(textStatus + " Error: " + XMLHttpRequest.responseText);
            }
        });
    }
</script>

<script>
    $(function () { $("input,select,textarea").not("[type=submit]").jqBootstrapValidation(); });
</script>

}
